<div class="roles_box">
    <!-- 面包屑 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>权限管理</el-breadcrumb-item>
        <el-breadcrumb-item>角色列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 添加按钮 -->
    <el-row class="add_box">
        <el-button @click="() => this.addRolesDialog = true" type="warning">添加角色</el-button>
    </el-row>
    <!-- 带有二级展开的表格 -->
    <el-row class="rolesTable_box">
        <el-table
        :data="roleList"
        border
        style="width: 100%">
        <el-table-column type="expand">
          <template slot-scope="data">
            <!-- 二级表格 -->
            <el-row class="first" v-for="first in data.row.children" :key="first.id">
                <el-col :span="4">
                    <el-tag @close="deleteRightHandler(data.row.id, first.id)" closable>{{ first.authName }}</el-tag>
                </el-col>
                <el-col :span="20">
                    <el-row class="second" v-for="second in first.children" :key="second.id">
                        <el-col :span="4">
                            <el-tag @close="deleteRightHandler(data.row.id, second.id)" closable type="warning">{{ second.authName }}</el-tag>
                        </el-col>
                        <el-col :span="20">
                            <el-col class="third" v-for="third in second.children" :key="third.id" :span="4">
                                <el-tag @close="deleteRightHandler(data.row.id, third.id)" type="success" closable>{{ third.authName }}</el-tag>
                            </el-col>
                        </el-col>
                    </el-row>
                </el-col>
            </el-row>
          </template>
        </el-table-column>
        <el-table-column
          label="序号"
          type="index"
          width="80">
        </el-table-column>
        <el-table-column
          label="角色名称"
          prop="roleName"
          width="160">
        </el-table-column>
        <el-table-column
          label="角色描述"
          prop="roleDesc"
          width="220">
        </el-table-column>
        <el-table-column
            label="操作">
            <template slot-scope="data">
                <el-tooltip class="item" effect="dark" content="编辑" placement="left">
                <el-button @click="showEditInfoDialog(data.row)" icon="el-icon-edit" size="mini" type="success" circle></el-button>
                </el-tooltip>
                <el-tooltip class="item" effect="dark" content="删除" placement="top">
                <el-button @click="deleteRolesHandler(data.row.id)" icon="el-icon-delete" size="mini" type="danger" circle></el-button>
                </el-tooltip>
                <el-tooltip class="item" effect="dark" content="分配权限" placement="right">
                <el-button @click="showEditRightsHandler(data.row.children, data.row.id)" icon="el-icon-setting" size="mini" type="primary" circle></el-button>
                </el-tooltip>
            </template>
        </el-table-column>
      </el-table>
    </el-row>
    <!-- 添加角色对话框 -->
    <el-dialog @closed="closeAddUserDialogHandler" title="添加角色" :visible.sync="addRolesDialog">
        <el-form :rules="addRolesRules" ref="addRoles" :model="addRolesInfo">
          <el-form-item prop="roleName" label="角色名称" label-width="800">
            <el-input v-model="addRolesInfo.roleName" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item prop="roleDesc" label="角色描述" label-width="800">
            <el-input v-model="addRolesInfo.roleDesc" autocomplete="off"></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="() => this.addRolesDialog = false">取 消</el-button>
          <el-button @click="addRolesHandler" type="success">添 加</el-button>
        </div>
    </el-dialog>
    <!-- 编辑权限信息对话框 -->
    <el-dialog title="编辑角色" :visible.sync="editRolesInfoDialog">
        <el-form ref="addRoles" :rules="addRolesRules" :model="editRolesInfo">
        <el-form-item label="角色名称" prop="roleName" label-width="800">
            <el-input v-model="editRolesInfo.roleName" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="角色描述" prop="roleDesc" label-width="800">
            <el-input v-model="editRolesInfo.roleDesc" autocomplete="off"></el-input>
        </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
        <!-- 点击取消按钮的时候, 关闭对话框 -->
        <el-button @click="() => this.editRolesInfoDialog = false">取 消</el-button>
        <!-- 点击确认编辑按钮的时候, 发送请求修改内容 -->
        <el-button @click="editRolesInfoHandler" type="success">确认编辑</el-button>
        </div>
    </el-dialog>
    <!-- 分配权限对话框 -->
    <el-dialog @closed="closeRightsDialog" title="分配权限" :visible.sync="editRightsDialog">
        <el-tree
        ref="rightsTree"
        v-if="editRightsDialog"
        :data="rightsList"
        show-checkbox
        node-key="id"
        :default-expanded-keys="expendRightsList"
        :default-checked-keys="checkedRightsList"
        :props="rightsTreeInfo">
        </el-tree>

        <div slot="footer" class="dialog-footer">
        <el-button @click="() => this.editRightsDialog = false">取 消</el-button>
        <el-button @click="editRightHandler" type="success">确认权限分配</el-button>
        </div>
    </el-dialog>
</div>